#! /usr/bin/env python

import waflib.Task, waflib.TaskGen
from waflib.TaskGen import extension
import os, sys

def create_protoc_task(name, type):
    return waflib.Task.task_factory(name, 
                                    'protoc --encode=%s -I ../src/test -I ../proto -I ${DYNAMO_HOME}/share/proto -I ${DYNAMO_HOME}/ext/include ../proto/input/input_ddf.proto < ${SRC} > ${TGT}' % type,
                                    before='c cxx',
                                    shell=True,
                                    color='PINK')

create_protoc_task('input_binding', 'dmInputDDF.InputBinding')
create_protoc_task('gamepads', 'dmInputDDF.GamepadMaps')

@extension('.input_binding')
def extension_cont_pb(self, node):
    task = self.create_task('input_binding')
    task.set_inputs(node)
    out = node.change_ext('.input_bindingc')
    task.set_outputs(out)

@extension('.gamepads')
def extension_cont_pb(self, node):
    task = self.create_task('gamepads')
    task.set_inputs(node)
    out = node.change_ext('.gamepadsc')
    task.set_outputs(out)

def build(bld):
    test_input = bld(features = 'cc cxx cprogram test',
                     includes = '. .. ../../proto',
                     use = 'TESTMAIN PROFILE_NULL DDF SOCKET PLATFORM_THREAD PLATFORM_NULL HID_NULL DLIB input',
                     source = bld.path.ant_glob('*', excl='wscript'),
                     protoc_includes = '../../proto',
                     target = 'test_input')

    test_input.install_path = None
